"""
使用此脚本将数据转换到数据库, 或者将数据库中的数据转为json文件
"""
import json
from pathlib import Path

DATA_DIR = Path("../data")
DIST_DIR = Path("../dist")

DATA_DIR.mkdir(exist_ok=True)
DIST_DIR.mkdir(exist_ok=True)


def main():
    result = {}
    for file_ins in DATA_DIR.rglob('**/*.json'):
        try:
            file_data = json.loads(file_ins.read_text(encoding="utf-8"))
            json_data = json.dumps(file_data, ensure_ascii=False, indent=4)
            print(json_data)
        except Exception as e:
            print(f"error: {e}")

    print(json.dumps(result, ensure_ascii=False, indent=4))


if __name__ == "__main__":
    main()
